//app.js
App({
  onLaunch: function() {
    //调用API从本地缓存中获取数据
    var logs = wx.getStorageSync('logs') || []
    let that = this;
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    wx.getSystemInfo({
      success: res => {
        // console.log('手机信息res'+res.model)
        let modelmes = res.model;
        if (modelmes.search('iPhone X') != -1 || (modelmes.search('unknown') != -1 && modelmes.search('iPhone') != -1)) {
          that.globalData.url = that.globalData.url + '?device=fullscreen'
          console.log(that.globalData.url)
        }
      }
    })
  },

  getUserInfo: function(cb) {
    var that = this
    if (this.globalData.userInfo) {
      typeof cb == "function" && cb(this.globalData.userInfo)
    } else {
      //调用登录接口
      wx.getUserInfo({
        withCredentials: false,
        success: function(res) {
          that.globalData.userInfo = res.userInfo
          typeof cb == "function" && cb(that.globalData.userInfo)
        }
      })
    }
  },

  globalData: {
    //网页域名 就是网页首页
    url: "https://hpy.izhixiu.cn/front/#/mall",
    //支付结果页面
    weburl: "",
    //支付接口
    wxpayApi: "https://hpy.izhixiu.cn/api/front/appletPay/appletPay",

    //小程序appid
    appid: "wx47d55dea549d3da1",

    //秘钥
    secret: "a04531e7107e9ddcf3ea4437871707e2"
  },

  onHide() {
    this.data.webShowed = false;
  },
  data: {
    webShowed: false //标记web-view页面是否已经显示过了
  }

})